﻿#include "sb.h"

const char* shs =
"public test;\n" \
"test = 1;\n" \
"test2 = \"test1: \" + test;\n" \
"print(test2, \"\\n\");\n" \
"print( format(\"test2: %d\", test), \"\\n\" );\n";

int main(void)
{
	k_mesgs("test!!!\n");

	//
	k_mesgf("-> %'d\n", 123456789);

	//
#if 0
	kHfs* hfs = kHfs::New("e:\\@.hfs");
	if (hfs)
	{
		hfs->SetDir("texture");

		kFileList* fl = hfs->Files(NULL);
		if (fl)
		{
			kFileInfo i;
			if (fl->First(&i))
			{
				do
				{
					k_mesgf("-> %s\n", i.name);
				} while (fl->Next(&i));
			}

			fl->Unload();
		}

		hfs->Unload();
	}
#endif

	//
	kHsMachine* hsm = kHsMachine::New();
	if (hsm)
	{
		//kCardinalFunction* rfn = hsm->CompileFile(NULL, "e:\\zz.hs", "e:\\zz.txt");
		kCardinalFunction* rfn = hsm->Compile(NULL, shs, "hsfile", "d:\\zz.txt");

		if (rfn)
		{
			kHsRun* run = hsm->CreateRun(rfn);
			run->Run();
			run->Unload();

			rfn->Unload();
		}

		//
		rfn = hsm->CompileFile("hsfile", "d:\\dk.hs", "d:\\dkhs.txt");
		if (rfn)
		{
			kHsRun* run = hsm->CreateRun(rfn);
			run->Run();
			run->Unload();

			rfn->Unload();
		}

		hsm->Unload();
	}

	//
	kCardinalString* cs = kCardinalString::New("test");
	kSymbol s1 = cs->TrySymbol();
	kSymbol s2 = cs->BuildSymbol();
	k_mesgf("%s(%d) %u, %u\n", cs->GetData(), cs->GetLength(), s1.Value(), s2.Value());
	cs->Unload();

	return 0;
}

